/**
 * 多线程例子
 */
package edu.gzz.thread;

public class MainApp {

	public static void main(String[] args) throws InterruptedException {
		// 创建线程
		final int THREAD_NUM = 4;
		SimpleThread[] threads = new SimpleThread[THREAD_NUM];

		for (int i = 0; i < threads.length; i++) {
			threads[i] = new SimpleThread();
			threads[i].setName("t" + String.valueOf(i));
			System.out.println(threads[i].getState());
		}

		System.out.println(Thread.currentThread().getName());
		
		//先运行t0线程
		threads[0].start();

		// 等待t0线程运行结束后再运行其他线程
		threads[0].join();
		System.out.println(threads[0].getState());
		System.out.println();

		for (SimpleThread t : threads) {

			if (t.getName().equals("t0")) {
				continue;
			}

			t.start();
		}
	}
}
